/**
 * 
 */
package ua.kpi.javatrainee6.model.utils;

/**
 * Address representation, is used by Department and Person classes
 *
 */
public final class Address {
	
	private static int id = 0;
	private String country;
	private String city;
	private String street;
	private int buildingNumber;
	private int appartmentNumber;
	private String zipCode;
	
	public Address(String country, String city, String street, int buildingNumber, 
			       int appartmentNumber, String zipCode) {
		this.country = country;
		this.city = city;
		this.street = street;
		this.buildingNumber = buildingNumber;
		this.appartmentNumber = appartmentNumber;
		this.zipCode = zipCode;
	}
	
	public Address() {
		id++;
		this.country = "country" + id;
		this.city = "city" + id ;
		this.street = "street" + id;
		this.buildingNumber = id;
		this.appartmentNumber = id;
		this.zipCode = "zipCode" + id;
	}
	
	@Override
	public String toString() {
		return String.format("Address: %s - %s,%s, %s %d, app %d", country, zipCode, 
				              city, street, buildingNumber, appartmentNumber);
	}
	
	@Override
	public boolean equals(Object otherObject) {
		if (this == otherObject) {
			return true;
		}
		if (otherObject == null) {
			return false;
		}
		if (! (otherObject instanceof Address)) {
			return false;
		}
		Address other = (Address) otherObject;
		return ((country.equals(other.country) && city.equals(other.city))
		            && (street.equals(other.street) && buildingNumber == other.buildingNumber) 
		            && (appartmentNumber == other.appartmentNumber && zipCode.equals(other.zipCode)));                                
	}
}

